package com.qfedu.service;

import com.alibaba.fastjson.JSONObject;
import com.qfedu.dao.SingerDao;
import com.qfedu.entity.Singer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhang
 * @Title: commonValidateAdd
 * @date : 2022/2/22 20:43
 */
@Service
public class SingerServiceImpl implements SingerService{
    @Autowired
    private SingerDao singerDao;
    @Override
    public List<Singer> findAllSinger() {
        return singerDao.findAllSinger();
    }

    @Override
    public int addSinger(Singer singer) {
        return singerDao.addSinger(singer);
    }

    @Override
    public int deleteSinger(Singer singer) {
        return singerDao.deleteSinger(singer);
    }

    @Override
    public int updateSinger(Singer singer) {
        return singerDao.updateSinger(singer);
    }

    @Override
    public JSONObject updateSingerById(Singer singer) {
        int i = singerDao.updateSingerById(singer);
        JSONObject jsonObject = new JSONObject();
        if (i != 0){
            jsonObject.put("code",1);
            jsonObject.put("msg","更改成功");

        }else {
            jsonObject.put("code",0);
            jsonObject.put("msg","更改成功");
        }
        return jsonObject;
    }


}
